package cn.ming.wfchat.app.me.adpter;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import cn.ming.wfchat.R;
import cn.ming.wfchat.app.dialog.ExchangeUsdtListDialog;
import cn.ming.wfchat.app.me.activity.MyAssetsTopUpActivity;
import cn.ming.wfchat.app.me.activity.MyAssetsWithdrawalActivity;
import cn.ming.wfchat.app.me.activity.model.AssetsBean;

/**
 * @author luoming
 * created at 2019/8/27 6:09 PM
 */

public class AssetsListAdapter extends BaseQuickAdapter<AssetsBean.ListBean, BaseViewHolder> {


    public AssetsListAdapter() {
        super(R.layout.currency_usdt_item);
    }


    @Override
    protected void convert(BaseViewHolder helper, AssetsBean.ListBean item) {
        helper.setText(R.id.tv_type, item.getCoinType());
        helper.setText(R.id.tv_balance, "可用：" + item.getMainBalance().toPlainString() + item.getCoinType());
        helper.setText(R.id.tv_frozenBalance, "实时指数：" + item.getRate() + "    估值：" + item.getValuationBanlance().toPlainString());
        helper.getView(R.id.ll_layout).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ExchangeUsdtListDialog.newInstance().setOnClickListener(new ExchangeUsdtListDialog.OnClickListener() {
                    @Override
                    public void topUp() {
                        Intent intent = new Intent(mContext, MyAssetsTopUpActivity.class);
                        intent.putExtra("coinType", item.getCoinType());
                        mContext.startActivity(intent);
                    }

                    @Override
                    public void withdrawal() {
                        Intent intent = new Intent(mContext, MyAssetsWithdrawalActivity.class);
                        intent.putExtra("coinType", item.getCoinType());
                        mContext.startActivity(intent);
                    }
                }).show(mContext);
            }
        });
        ImageView imageView = helper.getView(R.id.iv_type);
        if (item.getCoinType().equals("ETH")) {
            imageView.setImageResource(R.mipmap.icon_eth);

        } else if (item.getCoinType().equals("TRX")) {
            imageView.setImageResource(R.mipmap.icon_rtx);
        } else {
            imageView.setImageResource(R.mipmap.icon_usdt);
        }
    }
}
